package org.lanqiao.tjut.action;

import java.util.Map;

import org.apache.struts2.ServletActionContext;
import org.lanqiao.tjut.bean.AdminBean;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class AdminInfoAction extends ActionSupport {

	/**
	 * 定义一个实体类：需要提供setter接口 
	 * 该实体类可以和form表单数据进行映射 
	 * 如果form表单的name属性值会和该实体类产生映射关系
	 * name属性：实体变量名.属性名
	 */
	private AdminBean adminB;
	
	private String adminName;
	private String adminPsw;
	
	private static final long serialVersionUID = 1L;

	@Override
	public String execute() throws Exception {
		// action的默认响应方法
		return super.execute();
	}

	public String doAdminLogin() {
		// 进行管理员登录请求的转发处理
		System.out.println("当前登录的用户信息：" + (adminB == null?"":adminB.toString()));
		System.out.println("当前登录用户名："+adminName);
		// 如果业务逻辑成功：则返回"success";如果处理失败，则返回 "failed"或者是"input"字符串
		
		// actioncontext中获取servlet相关的对象
		// 获取session对象
		Map<String, Object> session = ActionContext.getContext().getSession();
		// 获取request对象有三种方式
		ActionContext.getContext().get("request");
		ServletActionContext.getRequest();
		return "chenggong";
	}

	public AdminBean getAdminB() {
		return adminB;
	}

	public void setAdminB(AdminBean adminB) {
		this.adminB = adminB;
	}

	public String getAdminName() {
		return adminName;
	}

	public void setAdminName(String adminName) {
		this.adminName = adminName;
	}

	public String getAdminPsw() {
		return adminPsw;
	}

	public void setAdminPsw(String adminPsw) {
		this.adminPsw = adminPsw;
	}

	
}
